import {BaseController} from './BaseController'
import {LoginModel} from '../../client/Model/LoginModel'
import {UserModel} from '../Model/UserModel'

class LoginController extends BaseController {
    constructor() {
        super()
        this.loginModel = new LoginModel()
    }

    login(type,options) {
        // 验证输入
        LoginModel.validate(options,function () {
            // 用户交互后调用
            let loginResult=this.loginModel.login(type,options)

            if (loginResult.status) {
                this.user=new UserModel(loginResult.data)
                // update view
            } else {
                this.loginModel.showError(loginResult.errorMsg)
            }
        })


    }
}

export {
    LoginController
}